package com.egame.manage.biz.web.controller.op;

import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import cn.egame.common.model.PageData;
import cn.egame.common.servlet.WebUtils;
import cn.egame.common.util.Utils;
import cn.egame.ext.EnumTypeExt.OperationActivityPosition;
import cn.egame.ext.EnumTypeExt.OperationActivityRecordType;
import cn.egame.ext.op.OperationActivityInfo;
import cn.egame.interfaces.ConstVar;
import cn.egame.interfaces.EnumType.GameType;
import cn.egame.interfaces.fl.FileInfo;
import cn.egame.interfaces.fl.FileUsedType;
import cn.egame.interfaces.fl.FileUtils;
import cn.egame.interfaces.gc.TerminalInfo;
import com.egame.manage.biz.server.ManageClient;
import com.egame.manage.biz.server.ManageClientExt;
import com.egame.manage.biz.server.gc.GameServiceImpl;
import com.egame.manage.biz.server.gc.TerminalServiceImpl;
import com.egame.manage.biz.server.op.OperationActivityServiceImpl;
import com.egame.manage.biz.web.controller.BaseController;
import com.lenovo.manager.business.domain.UserBean;

@Controller
@RequestMapping("/tv/activity")
public class ActivityController extends BaseController  {
	
	public ActivityController(){		
	}
	public ActivityController(HttpServletRequest req, HttpServletResponse resp) {
		super(req, resp);
	}
	
	@RequestMapping(value = "/list", method = {RequestMethod.GET,RequestMethod.POST})
	public ModelAndView listActivity(HttpServletRequest req, HttpServletResponse resp) throws Exception{
		if(req.getSession().getAttribute(com.egame.manage.biz.utils.ConstVar.USER_SESSION_KEY) != null){
			UserBean userBean = (UserBean) req.getSession().getAttribute(com.egame.manage.biz.utils.ConstVar.USER_SESSION_KEY);
			loginUserId = userBean.getOperatorId();
		}	
		int page = WebUtils.getInt(req,"page",0);
		int rowsOfPage = WebUtils.getInt(req,"rowsOfPage",15);
		String banner = WebUtils.getString(req, "banner","");
		int recordType = WebUtils.getInt(req, "recordTypeNum", OperationActivityRecordType.none.value());
		int position = WebUtils.getInt(req, "position", OperationActivityPosition.none.value());
		String beginTime = WebUtils.getString(req, "beginTime","");
		String endTime = WebUtils.getString(req, "endTime","");
		OperationActivityInfo bean = new OperationActivityInfo();
		bean.setDataStatus(1);
		bean.setDescription(banner);
		bean.setRecordType(OperationActivityRecordType.lookup(recordType));
		bean.setPosition(position);
		bean.setBeginString(beginTime);
		bean.setEndString(endTime);
		List<Integer> positionList = new ArrayList<Integer>();
		positionList.add(OperationActivityPosition.hotPosition.value());
		positionList.add(OperationActivityPosition.newPosition.value());
		positionList.add(OperationActivityPosition.loadingPosition.value());
		positionList.add(OperationActivityPosition.popUpAds.value());
//		List<Integer> terminalIds = TerminalServiceImpl.getInstance().listTerminalInfoByNotManufactureId(appId, loginUserId, com.egame.manage.biz.utils.ConstVar.HX_TYPE);
		PageData pd = OperationActivityServiceImpl.getInstance().pageActivity(appId, loginUserId, bean, null,positionList,page, rowsOfPage);	
		ModelAndView mv = new ModelAndView("/new/op/activityList");		
		mv.addObject("typeNum",recordType);
		mv.addObject("adPos",position);
		mv.addObject("pd", pd);
		mv.addObject("pdUrl", "/tv/activity/list");
		mv.addObject("para", 0);
		mv.addObject("banner", banner);
		mv.addObject("beginTime", beginTime);
		mv.addObject("endTime", endTime);
		
		return mv;
	}
	
	@RequestMapping(value = "/history/list", method = {RequestMethod.GET,RequestMethod.POST})
	public ModelAndView listHistoryActivity(HttpServletRequest req, HttpServletResponse resp) throws Exception{
		if(req.getSession().getAttribute(com.egame.manage.biz.utils.ConstVar.USER_SESSION_KEY) != null){
			UserBean userBean = (UserBean) req.getSession().getAttribute(com.egame.manage.biz.utils.ConstVar.USER_SESSION_KEY);
			loginUserId = userBean.getOperatorId();
		}
		ModelAndView mv = new ModelAndView("/new/op/activityHisList");
		int page = WebUtils.getInt(req,"page",0);
		int rowsOfPage = WebUtils.getInt(req,"rowsOfPage",15);		
		OperationActivityInfo bean = new OperationActivityInfo();
		bean.setDataStatus(0);
		List<Integer> positionList = new ArrayList<Integer>();
		positionList.add(OperationActivityPosition.hotPosition.value());
		positionList.add(OperationActivityPosition.newPosition.value());
		positionList.add(OperationActivityPosition.loadingPosition.value());
		positionList.add(OperationActivityPosition.popUpAds.value());
//		List<Integer> terminalIds = TerminalServiceImpl.getInstance().listTerminalInfoByNotManufactureId(appId, loginUserId, com.egame.manage.biz.utils.ConstVar.HX_TYPE);
		PageData pd = OperationActivityServiceImpl.getInstance().pageActivity(appId, loginUserId, bean, null,positionList,page, rowsOfPage);	
		mv.addObject("pd", pd);
		mv.addObject("pdUrl", "/tv/activity/history/list");
		mv.addObject("para", WebUtils.getInt(req, "para",0));
		
		return mv;
	}
	
	@RequestMapping(value = "/set", method = {RequestMethod.GET,RequestMethod.POST})
	public ModelAndView setAdvertisement(int file_type,OperationActivityInfo bean,HttpServletRequest req, HttpServletResponse resp)throws Exception{

		if(req.getSession().getAttribute(com.egame.manage.biz.utils.ConstVar.USER_SESSION_KEY) != null){
			UserBean userBean = (UserBean) req.getSession().getAttribute(com.egame.manage.biz.utils.ConstVar.USER_SESSION_KEY);
			loginUserId = userBean.getOperatorId();
		}
		try{							
			bean.setBeginTime(Utils.parseDate(bean.getBeginString()));
			bean.setEndTime(Utils.parseDate(bean.getEndString()));					
		}catch(Exception e){
			bean.setBeginTime(new Date());
			bean.setEndTime(new Date());
		}	
		bean.setRecordType(OperationActivityRecordType.lookup(bean.getRecordTypeNum()));
		bean.setDataStatus(1);			
		bean.setOperatorId(loginUserId);
		bean.setInsertTime(new Date());		
		int maxSortNo = OperationActivityServiceImpl.getInstance().getMaxSortNo(bean.getRecordTypeNum(), bean.getPosition());
		bean.setSortNo(1 + maxSortNo);	
		ManageClientExt.getInstance().setOperationActivityInfo(appId, loginUserId, bean);
		int activityId = OperationActivityServiceImpl.getInstance().getActivityId(bean.getPicId());
		List<Integer> terminalIds = TerminalServiceImpl.getInstance().listTerminalIds();	
		//int typical = ManageClientExt.getInstance().getTerminalIdByIsTypical(appId, loginUserId, 1, GameType.tv);
		//terminalIds.add(typical);
		for(int terminalId:terminalIds){
			OperationActivityServiceImpl.getInstance().addAdapt(activityId,terminalId);
		}	
		return listActivity(req,resp);
	}

	@RequestMapping(value = "/set/show", method = {RequestMethod.GET,RequestMethod.POST})
	public ModelAndView showNewAdvertisement(HttpServletRequest req, HttpServletResponse resp)throws Exception{
		return new ModelAndView("/new/op/newActivity");
	}	

	@RequestMapping(value = "/edit/show", method = {RequestMethod.GET,RequestMethod.POST})
	public ModelAndView showEditAdvertisement(int id,HttpServletRequest req, HttpServletResponse resp)throws Exception{
		
		OperationActivityInfo bean = ManageClientExt.getInstance().getOperationActivityInfoById(appId, loginUserId, id);		
		FileInfo file = ManageClient.getInstance().getFileInfo(appId, loginUserId, bean.getPicId());
		if(file == null) file = new FileInfo();
				
		ModelAndView mv = new ModelAndView("/new/op/editActivity"); 		
		String filepath =ConstVar.DOWNLOAD_URL + FileUtils.getFilePath(FileUsedType.adver_photo, bean.getPicId(), file.getFileName());
		
		mv.addObject("bean", bean);
		mv.addObject("filepath", filepath);
		mv.addObject("picname", file.getFileName());
		
		return mv;
	}
//	
//	@RequestMapping(value = "/update", method = {RequestMethod.GET,RequestMethod.POST})
//	public ModelAndView updateAdvertisement(int file_type,OperationActivityInfo bean,HttpServletRequest req, HttpServletResponse resp)throws Exception{
//		if(req.getSession().getAttribute(com.egame.manage.biz.utils.ConstVar.USER_SESSION_KEY) != null){
//			UserBean userBean = (UserBean) req.getSession().getAttribute(com.egame.manage.biz.utils.ConstVar.USER_SESSION_KEY);
//			loginUserId = userBean.getOperatorId();
//		}
////		MultipartFile file = ((MultipartHttpServletRequest)req).getFile("pic");		
////		long efsid = ManageClient.getInstance().writeToFile(file.getInputStream(),file_type,appId,loginUserId,file.getOriginalFilename());	
////		
////		if(efsid>0){
////			if(bean.getPicId()>0){//删除原图片
////				ManageClient.getInstance().deleteFileInfoById(appId, loginUserId, bean.getPicId());				
////			}
////			bean.setRecordType(OperationActivityRecordType.lookup(bean.getRecordTypeNum()));
////			bean.setUpdateTime(new Date());
////			bean.setPicId(efsid);
////			bean.setDataStatus(1);		
////			bean.setOperatorId(loginUserId);			
////			
////			ManageClientExt.getInstance().setOperationActivityInfo(appId, loginUserId, bean);
////		}		
//		bean.setRecordType(OperationActivityRecordType.lookup(bean.getRecordTypeNum()));
//		bean.setUpdateTime(new Date());
//		bean.setDataStatus(1);		
//		bean.setOperatorId(loginUserId);		
//		ManageClientExt.getInstance().setOperationActivityInfo(appId, loginUserId, bean);
//		return listActivity(req,resp);
//	}
//	
	@RequestMapping(value = "/delete", method = {RequestMethod.GET,RequestMethod.POST})
	public ModelAndView deleteAdvertisement(HttpServletRequest req, HttpServletResponse resp)throws Exception{
		if(req.getSession().getAttribute(com.egame.manage.biz.utils.ConstVar.USER_SESSION_KEY) != null){
			UserBean userBean = (UserBean) req.getSession().getAttribute(com.egame.manage.biz.utils.ConstVar.USER_SESSION_KEY);
			loginUserId = userBean.getOperatorId();
		}
		int activityId = WebUtils.getInt(req,"id",0);		
		OperationActivityServiceImpl.getInstance().deleteAdvertisement(appId, loginUserId, activityId);
		if(com.egame.manage.biz.utils.ConstVar.HX_TYPE == WebUtils.getInt(req, "para", 0)){
			return listHXActivity(req, resp);
		}else{
			return listActivity(req,resp);
		}		
	}
	
	@RequestMapping(value = "/adapt/show", method = {RequestMethod.GET,RequestMethod.POST})
	public ModelAndView showAdapt(HttpServletRequest req, HttpServletResponse resp)throws Exception{
		if(req.getSession().getAttribute(com.egame.manage.biz.utils.ConstVar.USER_SESSION_KEY) != null){
			UserBean userBean = (UserBean) req.getSession().getAttribute(com.egame.manage.biz.utils.ConstVar.USER_SESSION_KEY);
			loginUserId = userBean.getOperatorId();
		}
		ModelAndView mv = new ModelAndView("/new/op/activityAdapt"); 
		int activityId = WebUtils.getInt(req,"id",0);
		int page = WebUtils.getInt(req,"page",0);
		int rowsOfPage = WebUtils.getInt(req,"rowsOfPage",15);
		
		PageData pd = TerminalServiceImpl.getInstance().pageTerminalInfo(appId, loginUserId, activityId, page, rowsOfPage);
		mv.addObject("pd", pd);
		
		List<TerminalInfo> notAdaptList = TerminalServiceImpl.getInstance().listTerminalByNotAdapted(appId, loginUserId, activityId);
		mv.addObject("notAdaptList", notAdaptList);		
		mv.addObject("activityid", activityId);
		mv.addObject("para", WebUtils.getInt(req, "para",0));
		mv.addObject("pdUrl", "/tv/activity/adapt/show");
		return mv;
	}

	@RequestMapping(value = "/adapt/delete", method = {RequestMethod.GET,RequestMethod.POST})
	public ModelAndView deleteAdapt(HttpServletRequest req, HttpServletResponse resp)throws Exception{		
		int activityId = WebUtils.getInt(req,"id",0);
		int terminalId = WebUtils.getInt(req,"terminalid",0);		
		OperationActivityServiceImpl.getInstance().deleteAdapt(activityId, terminalId);		
		return showAdapt(req,resp);
	}

	@RequestMapping(value = "/adapt", method = {RequestMethod.GET,RequestMethod.POST})
	public ModelAndView adapt(HttpServletRequest req, HttpServletResponse resp)throws Exception{		
		int activityId = WebUtils.getInt(req,"id",0);
		int terminalId = WebUtils.getInt(req,"notAdapted",0);		
		OperationActivityServiceImpl.getInstance().addAdapt(activityId,terminalId);		
		return showAdapt(req,resp);
	}
	
	@ResponseBody
	@RequestMapping(value = "/image/width/height", method = {RequestMethod.GET,RequestMethod.POST})
	public String isFitImage(String name,int width,int height,int type,HttpServletRequest req, HttpServletResponse resp)throws Exception{
		if(req.getSession().getAttribute(com.egame.manage.biz.utils.ConstVar.USER_SESSION_KEY) != null){
			UserBean userBean = (UserBean) req.getSession().getAttribute(com.egame.manage.biz.utils.ConstVar.USER_SESSION_KEY);
			loginUserId = userBean.getOperatorId();
		}
		resp.setContentType("text/plain; charset=UTF-8");
		MultipartFile file = ((MultipartHttpServletRequest)req).getFile(name);			
		BufferedImage bf = null;
		if(file != null){
			bf = ImageIO.read(file.getInputStream());
		}		
		if(bf != null){
			if(bf.getWidth() == width && bf.getHeight() == height){
				if(file != null){
					long efsid = ManageClient.getInstance().writeToFile(file.getInputStream(),type,appId,loginUserId,file.getOriginalFilename());	
					if(efsid>0){
						return "" + efsid + "," +GameServiceImpl.getInstance().getImagePath(appId, loginUserId, efsid);
					}
				}	
			}			
		}		
		return "-1,-1"; 
	}
	

	@RequestMapping(value = "/list/HX", method = {RequestMethod.GET,RequestMethod.POST})
	public ModelAndView listHXActivity(HttpServletRequest req, HttpServletResponse resp) throws Exception{
		if(req.getSession().getAttribute(com.egame.manage.biz.utils.ConstVar.USER_SESSION_KEY) != null){
			UserBean userBean = (UserBean) req.getSession().getAttribute(com.egame.manage.biz.utils.ConstVar.USER_SESSION_KEY);
			loginUserId = userBean.getOperatorId();
		}	
		int page = WebUtils.getInt(req,"page",0);
		int rowsOfPage = WebUtils.getInt(req,"rowsOfPage",15);
		String banner = WebUtils.getString(req, "banner","");
		int recordType = WebUtils.getInt(req, "recordTypeNum", OperationActivityRecordType.none.value());
		int position = WebUtils.getInt(req, "position", OperationActivityPosition.none.value());
		String beginTime = WebUtils.getString(req, "beginTime","");
		String endTime = WebUtils.getString(req, "endTime","");
		
		List<Integer> terminalIds = TerminalServiceImpl.getInstance().listTerminalIds(com.egame.manage.biz.utils.ConstVar.HX_TYPE);		
		OperationActivityInfo bean = new OperationActivityInfo();
		bean.setDataStatus(1);
		bean.setDescription(banner);
		bean.setRecordType(OperationActivityRecordType.lookup(recordType));
		bean.setPosition(position);
		bean.setBeginString(beginTime);
		bean.setEndString(endTime);
		List<Integer> positionList = new ArrayList<Integer>();
		positionList.add(OperationActivityPosition.widgetPosition.value());
		PageData pd = OperationActivityServiceImpl.getInstance().pageActivity(appId, loginUserId, bean, terminalIds,positionList,page, rowsOfPage);	
		ModelAndView mv = new ModelAndView("/new/op/activityHXList");		
		mv.addObject("typeNum",recordType);
		mv.addObject("adPos",position);
		mv.addObject("pd", pd);
		mv.addObject("pdUrl", "/tv/activity/list");
		mv.addObject("para", com.egame.manage.biz.utils.ConstVar.HX_TYPE);
		mv.addObject("banner", banner);
		mv.addObject("beginTime", beginTime);
		mv.addObject("endTime", endTime);
		mv.addObject("recordType", recordType);
		mv.addObject("position", position);
		return mv;
	}

	@RequestMapping(value = "/set/HX", method = {RequestMethod.GET,RequestMethod.POST})
	public ModelAndView setHXAdvertisement(int file_type,OperationActivityInfo bean,HttpServletRequest req, HttpServletResponse resp)throws Exception{

		if(req.getSession().getAttribute(com.egame.manage.biz.utils.ConstVar.USER_SESSION_KEY) != null){
			UserBean userBean = (UserBean) req.getSession().getAttribute(com.egame.manage.biz.utils.ConstVar.USER_SESSION_KEY);
			loginUserId = userBean.getOperatorId();
		}
		try{							
			bean.setBeginTime(Utils.parseDate(bean.getBeginString()));
			bean.setEndTime(Utils.parseDate(bean.getEndString()));					
		}catch(Exception e){
			bean.setBeginTime(new Date());
			bean.setEndTime(new Date());
		}	
		bean.setRecordType(OperationActivityRecordType.lookup(bean.getRecordTypeNum()));
		bean.setDataStatus(1);
		int maxSortNo = OperationActivityServiceImpl.getInstance().getMaxSortNo(bean.getRecordTypeNum(), bean.getPosition());
		bean.setSortNo(1 + maxSortNo);	
		bean.setOperatorId(loginUserId);
		bean.setInsertTime(new Date());		
		if(bean.getgId()==1){
			OperationActivityServiceImpl.getInstance().updateBigPic(maxSortNo + 2);
		}else if(bean.getgId()>1){
			OperationActivityServiceImpl.getInstance().deleteBigPic();
		}
		ManageClientExt.getInstance().setOperationActivityInfo(appId, loginUserId, bean);		
		int activityId = OperationActivityServiceImpl.getInstance().getActivityId(bean.getPicId());
		List<Integer> terminalIds = TerminalServiceImpl.getInstance().listTerminalIds(com.egame.manage.biz.utils.ConstVar.HX_TYPE);
		int typical = ManageClientExt.getInstance().getTerminalIdByIsTypical(appId, loginUserId, 1, GameType.tv);
		terminalIds.add(typical);
		for(int terminalId:terminalIds){
			OperationActivityServiceImpl.getInstance().addAdapt(activityId,terminalId);
		}	
		return listHXActivity(req, resp);
	}

	@RequestMapping(value = "/history/list/HX", method = {RequestMethod.GET,RequestMethod.POST})
	public ModelAndView listHXHistoryActivity(HttpServletRequest req, HttpServletResponse resp) throws Exception{
		if(req.getSession().getAttribute(com.egame.manage.biz.utils.ConstVar.USER_SESSION_KEY) != null){
			UserBean userBean = (UserBean) req.getSession().getAttribute(com.egame.manage.biz.utils.ConstVar.USER_SESSION_KEY);
			loginUserId = userBean.getOperatorId();
		}
		ModelAndView mv = new ModelAndView("/new/op/activityHisList");
		int page = WebUtils.getInt(req,"page",0);
		int rowsOfPage = WebUtils.getInt(req,"rowsOfPage",15);			
		List<Integer> terminalIds = TerminalServiceImpl.getInstance().listTerminalIds(com.egame.manage.biz.utils.ConstVar.HX_TYPE);		
		OperationActivityInfo bean = new OperationActivityInfo();
		bean.setDataStatus(0);
		List<Integer> positionList = new ArrayList<Integer>();
		positionList.add(OperationActivityPosition.widgetPosition.value());
		PageData pd = OperationActivityServiceImpl.getInstance().pageActivity(appId, loginUserId, bean, terminalIds,positionList,page, rowsOfPage);	
		mv.addObject("pd", pd);
		mv.addObject("pdUrl", "/tv/activity/history/list/HX");
		mv.addObject("para", WebUtils.getInt(req, "para",0));
		
		return mv;
	}

	@RequestMapping(value = "/HX/set/show", method = {RequestMethod.GET,RequestMethod.POST})
	public ModelAndView showHXNewAdvertisement(HttpServletRequest req, HttpServletResponse resp)throws Exception{
		ModelAndView mv = new ModelAndView("/new/op/newHXActivity"); 		
		mv.addObject("para", com.egame.manage.biz.utils.ConstVar.HX_TYPE);
		return mv;
	}	

	@RequestMapping(value = "/HX/edit/show", method = {RequestMethod.GET,RequestMethod.POST})
	public ModelAndView showHXEditAdvertisement(int id,HttpServletRequest req, HttpServletResponse resp)throws Exception{
		
		OperationActivityInfo bean = ManageClientExt.getInstance().getOperationActivityInfoById(appId, loginUserId, id);		
		FileInfo file = ManageClient.getInstance().getFileInfo(appId, loginUserId, bean.getPicId());
		if(file == null) file = new FileInfo();
				
		ModelAndView mv = new ModelAndView("/new/op/editHXActivity"); 		
		String filepath =ConstVar.DOWNLOAD_URL + FileUtils.getFilePath(FileUsedType.adver_photo, bean.getPicId(), file.getFileName());
		
		mv.addObject("bean", bean);
		mv.addObject("filepath", filepath);
		mv.addObject("para", com.egame.manage.biz.utils.ConstVar.HX_TYPE);
		mv.addObject("picname", file.getFileName());
		
		return mv;
	}
//
//	@RequestMapping(value = "/update/HX", method = {RequestMethod.GET,RequestMethod.POST})
//	public ModelAndView updateHXAdvertisement(int file_type,OperationActivityInfo bean,HttpServletRequest req, HttpServletResponse resp)throws Exception{
//		if(req.getSession().getAttribute(com.egame.manage.biz.utils.ConstVar.USER_SESSION_KEY) != null){
//			UserBean userBean = (UserBean) req.getSession().getAttribute(com.egame.manage.biz.utils.ConstVar.USER_SESSION_KEY);
//			loginUserId = userBean.getOperatorId();
//		}
////		//MultipartFile file = ((MultipartHttpServletRequest)req).getFile("pic");		
////		//long efsid = ManageClient.getInstance().writeToFile(file.getInputStream(),file_type,appId,loginUserId,file.getOriginalFilename());	
////		
////		if(efsid>0){
////			if(bean.getPicId()>0){//删除原图片
////				ManageClient.getInstance().deleteFileInfoById(appId, loginUserId, bean.getPicId());				
////			}
////			bean.setRecordType(OperationActivityRecordType.lookup(bean.getRecordTypeNum()));
////			bean.setUpdateTime(new Date());
////			bean.setPicId(efsid);
////			bean.setDataStatus(1);		
////			bean.setOperatorId(loginUserId);			
////			
////			ManageClientExt.getInstance().setOperationActivityInfo(appId, loginUserId, bean);
////		}
//		bean.setRecordType(OperationActivityRecordType.lookup(bean.getRecordTypeNum()));
//		bean.setUpdateTime(new Date());		
//		bean.setDataStatus(1);		
//		bean.setOperatorId(loginUserId);			
//		
//		ManageClientExt.getInstance().setOperationActivityInfo(appId, loginUserId, bean);
//		return listHXActivity(req, resp);
//	}
//	
	@RequestMapping(value = "/upper", method = {RequestMethod.GET,RequestMethod.POST})
	public ModelAndView upperSortNo(HttpServletRequest req, HttpServletResponse resp)throws Exception{
		if(req.getSession().getAttribute(com.egame.manage.biz.utils.ConstVar.USER_SESSION_KEY) != null){
			UserBean userBean = (UserBean) req.getSession().getAttribute(com.egame.manage.biz.utils.ConstVar.USER_SESSION_KEY);
			loginUserId = userBean.getOperatorId();
		}
		int activityId = WebUtils.getInt(req,"id",0);
		OperationActivityServiceImpl.getInstance().upper(appId, loginUserId, activityId);		
		return listHXActivity(req,resp);
	}	

	@RequestMapping(value = "/lower", method = {RequestMethod.GET,RequestMethod.POST})
	public ModelAndView lowerSortNo(HttpServletRequest req, HttpServletResponse resp)throws Exception{
		if(req.getSession().getAttribute(com.egame.manage.biz.utils.ConstVar.USER_SESSION_KEY) != null){
			UserBean userBean = (UserBean) req.getSession().getAttribute(com.egame.manage.biz.utils.ConstVar.USER_SESSION_KEY);
			loginUserId = userBean.getOperatorId();
		}
		int activityId = WebUtils.getInt(req,"id",0);
		OperationActivityServiceImpl.getInstance().lower(appId, loginUserId, activityId);
		return listHXActivity(req,resp);
	}	

}
